package cn.jia.spring4.config;

import cn.jia.spring2.pojo.InterfaceImpl.BlankDisc;
import cn.jia.spring2.pojo.InterfaceImpl.SgtPeppers;
import cn.jia.spring2.pojo.myInterface.CompactDisc;
import cn.jia.spring4.annotation.BlankAnnotation;
import cn.jia.spring4.aspect.Audience;
import cn.jia.spring4.aspect.EncoreableAspect;
import cn.jia.spring4.aspect.TrackCounter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jia on 2018/4/2.
 */
@Configuration
//@ComponentScan("cn.jia.spring2.pojo.InterfaceImpl")
@ComponentScan("cn.jia.spring4")
//启动AspectJ自动代理
@EnableAspectJAutoProxy
public class ConcertConfig {
    //也可以添加@Component注解创建该类
    //注册切面类，当切面类中需要使用其他类的实例，我们不能这样创建切面bean。
    @Bean("audience")
    public Audience audience() {
        return new Audience();
    }
    @Bean
    //使用@Qualifier限定符限定注入名称
    //@Qualifier("blankDisc")
    @BlankAnnotation //自定义限定符注解
    public CompactDisc blankDisc(){
        BlankDisc blankDisc = new BlankDisc();
        blankDisc.setArtist("刘欢");
        blankDisc.setTitle("从头再来");
        List<String> list = new ArrayList<String>();
        list.add("1-");
        list.add("2-");
        list.add("3-");
        blankDisc.setTracks(list);
        return blankDisc;
    }
    @Bean
    public TrackCounter trackCounter(){
        return new TrackCounter();
    }
    @Bean
    public CompactDisc SgtPeppers(){
        return new SgtPeppers();
    }
    @Bean
    public EncoreableAspect encoreableAspect(){
        return new EncoreableAspect();
    }
}
